
using System;
using System.Collections.Generic;
using BTKERP.Model;
using BTKERP.DAL.DataAccess;
using System;

namespace BTKERP.DAL
{
	#region WarehouseStockDAL
	public class WarehouseStockDAL : DBContext
	{
		public List<WarehouseStock> GetAll()
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_WarehouseStocksSelectAll");
            return GetEntityList<WarehouseStock>(cmd);
        }

        public WarehouseStock GetById(Guid warehouseId,Guid productId)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_WarehouseStockSelect");
            cmd.AddParameter("@WarehouseId", warehouseId);
            cmd.AddParameter("@ProductId", productId);
            return GetSingleEntity<WarehouseStock>(cmd);
        }

		public List<WarehouseStock> GetByDynamicSQL(string sqlCondition)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_WarehouseStockSelectDynamic");
            cmd.AddParameter("@SQL", sqlCondition);
            return GetEntityList<WarehouseStock>(cmd);
        } 
		
        public bool DeleteById(Guid id)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_WarehouseStockDelete");
            cmd.AddParameter("@Id", id);
            return ExecuteCommand(cmd);
        }

        public WarehouseStock UpdateById(
		Guid paramWarehouseId,

		Guid paramProductId,

		decimal paramAvailableQty,

		decimal paramOutstandingQty,

		bool paramIsStock,

		Guid paramShelfId,

		string paramPosition,

		string paramStatus,

		string paramUpdatedBy,
		DateTime paramUpdateOn
			)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_WarehouseStockUpdate");
			cmd.AddParameter("@WarehouseId", paramWarehouseId);
			cmd.AddParameter("@ProductId", paramProductId);
			cmd.AddParameter("@AvailableQty", paramAvailableQty);
			cmd.AddParameter("@OutstandingQty", paramOutstandingQty);
			cmd.AddParameter("@IsStock", paramIsStock);
			cmd.AddParameter("@ShelfId", paramShelfId);
			cmd.AddParameter("@Position", paramPosition);
			cmd.AddParameter("@Status", paramStatus);
			cmd.AddParameter("@UpdatedBy", paramUpdatedBy);
            cmd.AddParameter("@UpdatedOn", DateTime.Now);
            return GetSingleEntity<WarehouseStock>(cmd);
        }
		
	}
	#endregion
}
